﻿using System;

namespace Wxy.Action
{
    [Serializable]
    public struct BeCancelledTag
    {
        // /// <summary>
        // /// 时间段
        // /// </summary>
        public PercentageRange percentageRange;

        /// <summary>
        /// 可以Cancel的CancelTag
        /// </summary>
        public string[] cancelTag;

        /// <summary>
        /// 动画融合出去的时间
        /// Unity推荐用normalized作为一个标尺，因为用second对于做动画本身有点要求
        /// </summary>
        public float fadeOutPercentage;

        /// <summary>
        /// 当从这里被Cancel，动作会增加多少优先级
        /// </summary>
        public int priority;

        /// <summary>
        /// 根据TempBeCancelledTag和产生这个Tag的百分比时间点，算出一个新的BeCancelledTag
        /// </summary>
        /// <param name="tempTag"></param>
        /// <param name="fromPercentage"></param>
        /// <returns></returns>
        public static BeCancelledTag FromTemp(TempCancelledTag tempTag, float fromPercentage) => new BeCancelledTag
        {
            percentageRange = new PercentageRange(fromPercentage, fromPercentage + tempTag.percentage),
            cancelTag = tempTag.cancelTag,
            fadeOutPercentage = tempTag.fadeOutPercentage,
            priority = tempTag.priority
        };
    }
}